package com.gamex.findit.service.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gamex.findit.dao.ImageMapper;
import com.gamex.findit.model.Company;
import com.gamex.findit.model.Image;
import com.gamex.findit.model.ImageCut;
import com.gamex.findit.service.ImageService;

/**
 * 게임이미지 서비스
 * @author james
 *
 */
@Service
public class ImageServiceImpl implements ImageService{
	
	private static final Logger logger = LoggerFactory.getLogger(ImageServiceImpl.class);

	@Autowired ImageMapper imageMapper;
	
	public List<Image> getImage(Image image) throws Exception {
		
		List<Image> images = null;
		try {
			images = imageMapper.selectImage(image);
		} catch (Exception e) {
			logger.error(e.getMessage());
		}
		return images;
	}

	@Override
	public int getImageCount(Image image) throws Exception {
		int count = 0 ;
		try {
			count = imageMapper.selectImageCount(image);
		} catch (Exception e) {
			logger.error(e.getMessage());
		}
		return count;
	}

	@Override
	public Image getImageView(Image image) {
		Image result = null;
		try {
			result = imageMapper.selectImageView(image);
		} catch (Exception e) {
			logger.error(e.getMessage());
		}
		return result;
	}

	@Override
	public ImageCut getImageCut(int imgId, int seq) {
		ImageCut image = null;
		try {
			image = imageMapper.selectImageCut(imgId, seq);
		} catch (Exception e) {
			logger.error(e.getMessage());
		}
		return image;
	}

	@Override
	public int insertImage(Image image) {
		int result = 0;
		try {
			result = imageMapper.insertImage(image);
		} catch (Exception e) {
			logger.error(e.getMessage());
		}
		return result;
	}

	@Override
	public void updateImage(Image image) {
		try {
			imageMapper.updateImage(image);
		} catch (Exception e) {
			logger.error(e.getMessage());
		}
	}

	@Override
	public void insertImageCut(ImageCut image) {
		try {
			imageMapper.insertImageCut(image);
		} catch (Exception e) {
			logger.error(e.getMessage());
		}
	}

	@Override
	public void updateImageCut(ImageCut image) {
		try {
			imageMapper.updateImageCut(image);
		} catch (Exception e) {
			logger.error(e.getMessage());
		}
	}

	@Override
	public void deleteImage(int imgId) {
		try {
			imageMapper.deleteImage(imgId);
		} catch (Exception e) {
			logger.error(e.getMessage());
		}
	}

	@Override
	public void deleteImageCut(int imgId) {
		try {
			imageMapper.deleteImageCut(imgId);
		} catch (Exception e) {
			logger.error(e.getMessage());
		}
	}

	@Override
	public List<Company> getCompany() {
		List<Company> company = null;
		try {
			company = imageMapper.selectCompany();
		} catch (Exception e) {
			logger.error(e.getMessage());
		}
		return company;
	}

	@Override
	public List<ImageCut> selectImageCutList(int imgId) {
		List<ImageCut> image = null;
		try {
			image = imageMapper.selectImageCutList(imgId);
		} catch (Exception e) {
			logger.error(e.getMessage());
		}
		return image;
	}

}
